std::atoi, std::atol, std::atoll

From Cppreference

Jump to: navigation, search
Defined in header <cstdlib>

int       atoi( const char *str );

long      atol( const char *str )

long long atoll( const char *str );
(C++0x feature)

Interprets an integer value in a character string pointed to by str.

Function discards any whitespace characters until first non-whitespace character is found. Then it takes as many characters as possible to form a valid integer number representation and converts them to integer value. The valid integer value consists of the following parts:

- (optional) plus or minus sign

- numeric digits

Contents

Parameters

str - pointer to the null-terminated character string to be interpreted

Return value

integer value corresponding to the contents of str on success. If the converted value falls out of range of corresponding return type, INT_MAX, INT_MIN, LONG_MAX, LONG_MIN, LLONG_MAX or LLONG_MIN is returned. If no conversion can be performed, 0 is returned.

Example

See also

strtol
strtoll
converts a character string to an integer value
(function)
strtoul
strtoull
converts a character string to an unsigned integer value
(function)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages